package com.yzkj.cpjxc.business.domain;

import com.yzkj.cpjxc.business.framework.common.ConstantParam;
import com.yzkj.cpjxc.business.framework.common.Constants;
import com.yzkj.cpjxc.business.framework.utils.CollectionHelp;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.type.Alias;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 系统角色实体类
 */
@Alias("SysRole")
public class SysRole extends CommonBean<SysRole> {

	private static final long serialVersionUID = 5364780336495100313L;

	/**
	 * 角色主键
	 */
	private String roleId;

	/**
	 * 角色名称
	 */
	private String roleName;

	/**
	 * 备注
	 */
	private String remark;

	/**
	 * 状态 1：启用   -1：停止
	 */
	private String status;

	//===============================================================================关联集合============================
	/**
	 * 具有的权限
	 */
	private List<SysAuthority> sysAuthoritys;

	/**
	 * 为了便于操作，加了这个方法
	 */
	public Set<SysAuthority> getSysAuthoritySet() {
		Set<SysAuthority> set = new HashSet<SysAuthority>();
		if (CollectionHelp.isNotBank(this.getSysAuthoritys())) {
			set.addAll(this.getSysAuthoritys());
		}
		return set;
	}

	/**
	 * 关联用户信息
	 */
	private List<SysUser> sysUsers;

	public List<SysAuthority> getSysAuthoritys() {
		return sysAuthoritys;
	}

	public void setSysAuthoritys(List<SysAuthority> sysAuthoritys) {
		this.sysAuthoritys = sysAuthoritys;
	}

	public List<SysUser> getSysUsers() {
		return sysUsers;
	}

	public void setSysUsers(List<SysUser> sysUsers) {
		this.sysUsers = sysUsers;
	}

	public String getStatusName() {
		if (StringUtils.isBlank(this.status)) {
			return ConstantParam.statusMap.get(Constants.STATUS_INACTIVE);
		}
		return ConstantParam.statusMap.get(this.status);
	}
	
	//===============================================================================关联集合============================

	public String getRoleId() {
		return roleId;
	}

	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return "SysRole [roleId=" + roleId + ", roleName=" + roleName + ", remark=" + remark + ", status=" + status + "]";
	}

}
